//package com.easypan.controller;
//
//import com.easypan.annotation.GlobalInterceptor;
//import com.easypan.annotation.VerifyParam;
//import com.easypan.component.RedisComponent;
//import com.easypan.entity.dto.SysSettingsDto;
//import com.easypan.entity.query.FileInfoQuery;
//import com.easypan.entity.query.UserInfoQuery;
//import com.easypan.entity.vo.PaginationResultVO;
//import com.easypan.entity.vo.ResponseVO;
//import com.easypan.entity.vo.UserInfoVO;
//import com.easypan.service.FileInfoService;
//import com.easypan.service.UserInfoService;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//@RestController("adminController")
//@RequestMapping("/admin")
//public class AdminController extends CommonFileController {
//
//    @Resource
//    private RedisComponent redisComponent;
//
//    @Resource
//    private UserInfoService userInfoService;
//
//    @Resource
//    private FileInfoService fileInfoService;
//
//    @RequestMapping("/getSysSettings")
//    @GlobalInterceptor(checkParams = true, checkAdmin = true)
//    public ResponseVO getSysSettings() {
//        return getSuccessResponseVO(redisComponent.getSysSettingsDto());
//    }
//
//
//    @RequestMapping("/saveSysSettings")
//    @GlobalInterceptor(checkParams = true, checkAdmin = true)
//    public ResponseVO saveSysSettings(
//            @VerifyParam(required = true) String registerEmailTitle,
//            @VerifyParam(required = true) String registerEmailContent,
//            @VerifyParam(required = true) Integer userInitUseSpace) {
//        SysSettingsDto sysSettingsDto = new SysSettingsDto();
//        sysSettingsDto.setRegisterEmailTitle(registerEmailTitle);
//        sysSettingsDto.setRegisterEmailContent(registerEmailContent);
//        sysSettingsDto.setUserInitUseSpace(userInitUseSpace);
//        redisComponent.saveSysSettingsDto(sysSettingsDto);
//        return getSuccessResponseVO(null);
//    }
//
//    @RequestMapping("/loadUserList")
//    @GlobalInterceptor(checkParams = true, checkAdmin = true)
//    public ResponseVO loadUser(UserInfoQuery userInfoQuery) {
//        userInfoQuery.setOrderBy("join_time desc");
//        PaginationResultVO resultVO = userInfoService.findListByPage(userInfoQuery);
//        return getSuccessResponseVO(convert2PaginationVO(resultVO, UserInfoVO.class));
//    }
//
//
//    @RequestMapping("/updateUserStatus")
//    @GlobalInterceptor(checkParams = true, checkAdmin = true)
//    public ResponseVO updateUserStatus(@VerifyParam(required = true) String userId, @VerifyParam(required = true) Integer status) {
//        userInfoService.updateUserStatus(userId, status);
//        return getSuccessResponseVO(null);
//    }
//
//    @RequestMapping("/updateUserSpace")
//    @GlobalInterceptor(checkParams = true, checkAdmin = true)
//    public ResponseVO updateUserSpace(@VerifyParam(required = true) String userId, @VerifyParam(required = true) Integer changeSpace) {
//        userInfoService.changeSpace(userId, changeSpace);
//        return getSuccessResponseVO(null);
//    }
//
//    /**
//     * 查询所有文件
//     *
//     * @param query
//     * @return
//     */
//    @RequestMapping("/loadFileList")
//    @GlobalInterceptor(checkParams = true, checkAdmin = true)
//    public ResponseVO loadDataList(FileInfoQuery query) {
//        query.setOrderBy("last_update_time desc");
//        query.setQueryNickName(true);
//        PaginationResultVO resultVO = fileInfoService.findListByPage(query);
//        return getSuccessResponseVO(resultVO);
//    }
//
//    @RequestMapping("/getFolderInfo")
//    @GlobalInterceptor(checkLogin = false, checkAdmin = true, checkParams = true)
//    public ResponseVO getFolderInfo(@VerifyParam(required = true) String path) {
//        return super.getFolderInfo(path, null);
//    }
//
//
//    @RequestMapping("/getFile/{userId}/{fileId}")
//    @GlobalInterceptor(checkParams = true, checkAdmin = true)
//    public void getFile(HttpServletResponse response,
//                        @PathVariable("userId") @VerifyParam(required = true) String userId,
//                        @PathVariable("fileId") @VerifyParam(required = true) String fileId) {
//        super.getFile(response, fileId, userId);
//    }
//
//
//    @RequestMapping("/ts/getVideoInfo/{userId}/{fileId}")
//    @GlobalInterceptor(checkParams = true, checkAdmin = true)
//    public void getVideoInfo(HttpServletResponse response,
//                             @PathVariable("userId") @VerifyParam(required = true) String userId,
//                             @PathVariable("fileId") @VerifyParam(required = true) String fileId) {
//        super.getFile(response, fileId, userId);
//    }
//
//    @RequestMapping("/createDownloadUrl/{userId}/{fileId}")
//    @GlobalInterceptor(checkParams = true, checkAdmin = true)
//    public ResponseVO createDownloadUrl(@PathVariable("userId") @VerifyParam(required = true) String userId,
//                                        @PathVariable("fileId") @VerifyParam(required = true) String fileId) {
//        return super.createDownloadUrl(fileId, userId);
//    }
//
//    /**
//     * 下载
//     *
//     * @param request
//     * @param response
//     * @throws Exception
//     */
//    @RequestMapping("/download/{code}")
//    @GlobalInterceptor(checkLogin = false, checkParams = true)
//    public void download(HttpServletRequest request, HttpServletResponse response,
//                         @PathVariable("code") @VerifyParam(required = true) String code) throws Exception {
//        super.download(request, response, code);
//    }
//
//
//    @RequestMapping("/delFile")
//    @GlobalInterceptor(checkParams = true, checkAdmin = true)
//    public ResponseVO delFile(@VerifyParam(required = true) String fileIdAndUserIds) {
//        String[] fileIdAndUserIdArray = fileIdAndUserIds.split(",");
//        for (String fileIdAndUserId : fileIdAndUserIdArray) {
//            String[] itemArray = fileIdAndUserId.split("_");
//            fileInfoService.delFileBatch(itemArray[0], itemArray[1], true);
//        }
//        return getSuccessResponseVO(null);
//    }
//
//    @RequestMapping("/changeSpace/{userId}/{space}")
//    public ResponseVO changeSpace(@PathVariable("userId") @VerifyParam(required = true) String userId,
//                                  @PathVariable("space") @VerifyParam(required = true) Integer space) {
//        userInfoService.changeSpace(userId, space);
//        return getSuccessResponseVO(null);
//    }
//}
